#!/bin/bash

# 优化SERVER获取方式
if [ -f ".namelock" ]; then
    SERVER=`cat .namelock`
else
    SERVER="ckwy"
fi


if [ "${SERVER}" == "" ]
then
        echo "path error!"
        exit 1
fi

PID=`ps aux | grep logic | grep -v grep | grep ${SERVER} | awk '{print $2}'`

if [ "${PID}" != "" ]
then
        echo "Stopping ${SERVER} logic..."
        kill ${PID}
		sleep 2
		
		ENGINE_PID=`ps aux | grep logic | grep -v grep | grep ${SERVER} | awk '{print $2}'`
		if [ "${ENGINE_PID}" == "" ]
		then
			echo "kill ${SERVER} logic ok!"
		fi
		
else
		echo "No ${SERVER} logic process found, exits."
        exit 1
fi
